package top.lcm889.juc.demo;

/**
 * @author Coder-lcm
 * @date 2021/4/10
 *  多线程的实现方式
 *      1. 继承Thread类。重写其run方法即可
 *
 */
public class TestThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            /**
             * 此处的getName()方法是线程实例的方法：主要是获取线程名称
             */
            System.out.println(getName() + " : " + i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        TestThread thread1 = new TestThread();
        TestThread thread2 = new TestThread();
        thread1.start();
        thread2.start();
        System.out.println(Thread.currentThread().getName());
    }
}
